package com.bsj.sipgateway.util;

import org.springframework.stereotype.Component;

/**
 * 流媒体端口生成器
 * @author bsj-chenjunkang
 * @date 2022/8/24
 */
@Component
public class MediaPortUtils {


    private String[] udpPortRangeArray = new String[2];

    private int currentPort = 0;


    private void getPortFromUdpPortRange() {
        if (currentPort == 0) {
//            String[] udpPortRangeStrArray = {"3988","3989"};
            String[] udpPortRangeStrArray = {"23888","3989"};
            udpPortRangeArray[0] = udpPortRangeStrArray[0];
            udpPortRangeArray[1] = udpPortRangeStrArray[1];
        }
        currentPort = 1;
    }
    public String getUdpPort(){
        if (currentPort==0){
            getPortFromUdpPortRange();
        }
        return udpPortRangeArray[0];
    }
    public String getTcpPort(){
        if (currentPort==0){
            getPortFromUdpPortRange();
        }
        return udpPortRangeArray[1];
    }

}
